package com.example.singleactivitytemplate.ui.fragment.basicSettings

import android.media.AudioManager
import androidx.lifecycle.MutableLiveData
import com.example.singleactivitytemplate.ui.base.BaseViewModel


class BasicSettingViewModel : BaseViewModel() {
    val mCurrentBrightness=MutableLiveData<Int>().apply { value=20 }
    val mCurrentVolume=MutableLiveData<Int>().apply { value=2 }


    private val maxBrightness = 202
    private val minBrightness = 22
    private val mBrightnessStep=20
    init {

    }

    /**
     * 减少亮度
     */
    fun brightnessMinus() {
        if (((mCurrentBrightness.value?.minus(mBrightnessStep))
                ?: minBrightness) >= minBrightness
        ) {
            mCurrentBrightness.value = mCurrentBrightness.value?.minus(mBrightnessStep)
        } else {
            mCurrentBrightness.value = minBrightness
        }
    }

    /**
     * 增加亮度
     */
    fun brightnessAdd() {
        if (((mCurrentBrightness.value?.plus(mBrightnessStep)
                ?: minBrightness) <= maxBrightness)
        ) {
            mCurrentBrightness.value = mCurrentBrightness.value?.plus(mBrightnessStep)
        } else {
            mCurrentBrightness.value = maxBrightness
        }
    }
    /**
     * 减少声音
     */
    fun volumeMinus() {
        if ((mCurrentVolume.value?.minus(2)?:2)>=2)
        {
            mCurrentVolume.value= mCurrentVolume.value?.minus(2)
            mCurrentVolume.value?.let {

            }
        }
    }

    /**
     * 增加声音
     */
    fun volumeAdd() {
        if ((mCurrentVolume.value?.plus(2)?:2)<=6)
        {
            mCurrentVolume.value=mCurrentVolume.value?.plus(2)
            mCurrentVolume.value?.let {

            }
        }
    }
}